Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Overlay): overlay support SSR, close #4205 #4923

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

FairyYang
Copy link
Collaborator

No description provided.

@eternalsky eternalsky linked an issue Aug 30, 2024 that may be closed by this pull request
@eternalsky eternalsky changed the base branch from master to next August 30, 2024 06:52
components/overlay/utils/find-node.ts Outdated Show resolved Hide resolved
components/overlay/position.tsx Outdated Show resolved Hide resolved
components/overlay/position.tsx Show resolved Hide resolved
@@ -111,7 +111,9 @@ class Popup extends Component<PopupProps, PopupState> {
delay: 200,
canCloseByTrigger: true,
followTrigger: false,
container: () => document.body,
container: () => {
if (typeof document !== 'undefined') return document.body;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里有必要加吗

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我理解是要的,因为在服务器端渲染(SSR)的过程中,React 组件的静态属性(如 static defaultProps)会在服务器端执行。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

执行的是函数声明,而不是函数本身的执行,函数本身不执行就没有问题。

components/overlay/overlay.tsx Outdated Show resolved Hide resolved
) {
return;
}
if (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里去掉 document 了之后好像就没有拆成两个 if 的意义了

@@ -622,7 +626,7 @@ class Overlay extends Component<OverlayV1Props, OverlayState> {
const path = [] as Array<HTMLElement | Document | Window>;
while (el) {
path.push(el);
if (el.tagName === 'HTML') {
if (el.tagName === 'HTML' && typeof document !== 'undefined') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里感觉也没有必要,都不是 ssr 周期里的

@eternalsky eternalsky merged commit 0471a9e into alibaba-fusion:next Sep 5, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Dialog]support ssr please
2 participants